'use strict';

// assert来自Node.js 的模块，用于浏览器。
const assert = require('assert');

module.exports = (options, app) => {
  return async function(ctx, next) {
    assert.deepEqual(options, app.config.hello);
    ctx.body = options.text;
    await next();
  };
};


//2
module.exports = options => {
  return async function responseTime(ctx, next) {
    const start = Date.now();
    await next();
    const cost = Date.now() - start;
    ctx.set(options.headerKey, `${cost}ms`);
  };
};